#pragma once

#include <QtCore/QFile>

#include "Core.h"
#include "Item.h"

class CopyItem : public Item
{
	Q_OBJECT

public:
	CopyItem(Core * aCore, const QString & aID)
		: Item(aID),
		  mCore(aCore)
	{
	}

	/// Return unique id of this item.
	virtual QUuid getID()
	{
		return "340F30D2-3E17-459A-91AF-8F5381DD688B";
	}

	/// Build current item.
	virtual bool build()
	{
		const QVariantMap & settings = mCore->getItemSettings(mID);

		QString source = settings.value("source").toString();
		QString target = settings.value("target").toString();

		QFile::copy(source, target);
	}

	/// This event triggers if some action happens with the child aItem.
	virtual bool childAction(Item::ChildAction aAction, Item * aItem)
	{
		// This item not supports child actions.
		return false;
	}

private:
	Core * mCore;
};